package com.hackerrank.contests.aug13.challenges.markandtoys;

import java.util.Arrays;
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), K = in.nextInt(), n[] = new int[N];
		for(int i = 0; i < N; i++)
			n[i] = in.nextInt();
		Arrays.sort(n);
		int r = K, i = 0;
		for(; n[i] < r; i++)
			r -= n[i];
		System.out.println(i);
	}
}
